#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head, * newhead = nullptr;
        while (cur)
        {
            ListNode* next = cur->next;
            cur->next = newhead;
            newhead = cur;
            cur = next;
        }
        return newhead;
    }
};